import request from '@/utils/request';

// 查询公告列表
export function listNotice(query) {
  return request({
    url: '/system/notice/list',
    method: 'get',
    params: query
  });
}

// 查询公告详细
export function getNotice(noticeId) {
  return request({
    url: '/system/notice/' + noticeId,
    method: 'get'
  });
}

// 新增公告
export function addNotice(data) {
  return request({
    url: '/system/notice',
    method: 'post',
    data: data
  });
}

// 修改公告
export function updateNotice(data) {
  return request({
    url: '/system/notice',
    method: 'put',
    data: data
  });
}

// 删除公告
export function delNotice(noticeId) {
  return request({
    url: '/system/notice/' + noticeId,
    method: 'delete'
  });
}

// 获取用户公告列表
export function getUserNoticeList(query) {
  return request({
    url: '/system/notice/user/list',
    method: 'get',
    params: query
  });
}

// 获取用户未读公告数量
export function getUserUnreadNoticeCount() {
  return request({
    url: '/system/notice/user/count',
    method: 'get'
  });
}

// 标记用户公告为已读
export function markUserNoticeAsRead(noticeId) {
  return request({
    url: '/system/notice/user/read',
    method: 'post',
    params: { noticeId }
  });
}

// 一键标记用户所有公告为已读
export function markAllUserNoticeAsRead() {
  return request({
    url: '/system/notice/user/read/all',
    method: 'post'
  });
}

// 获取用户指定分类未读数量
export function getUserUnreadNoticeCountInType(query) {
  return request({
    url: '/system/notice/user/unread/type/count',
    method: 'get',
    params: query
  });
}
